﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：QuartzJobFactory.cs
// 功能描述：TongTongMall.Quartz
// 
// Create User：jym 2017/02/16
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using Quartz;
using Quartz.Spi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TongTongMall.Dependecy;

namespace TongTongMall.Quartz.Quartz
{
    public class QuartzJobFactory : IJobFactory
    {
        private readonly IIocResolver _iocResolver;

        public QuartzJobFactory(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            return _iocResolver.Resolve<IJob>(bundle.JobDetail.JobType);
        }

        public void ReturnJob(IJob job)
        {
            _iocResolver.Release(job);
        }
    }
}
